package com.itdfq.consumer.consumer;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: QianMo
 * @Date: 2021/11/16 10:38
 * @Description:
 */
@Component
public class ReceiverDemo2 implements ChannelAwareMessageListener {
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("接收消息: " + message + " 接收时间：" + sdf.format(new Date()));
        throw new RuntimeException("测试异常处理");
    }
}
